package cn.com.template.utils;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import cn.com.dal.dataobject.sys.MenuDO;
import cn.com.support.context.MenuContext;

/**
 * 菜单工具
 * 
 * @since 2012-3-24 下午3:15:42
 * @version 1.0
 * @author Microbun
 * 
 */
public class MenuUtils {

	/**
	 * 获取子菜单，并且不带层级关系,即菜单的子菜单不带子菜单
	 * 
	 * @param menu
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public static Map<Object, Object>[] gainChildrenMenusWhitoutHierarchy(MenuDO menu) {
		Map<Object, Object>[] children=null;
		if (menu.getChildren()==null){
			return null;
		}else{
			children = new HashMap[menu.getChildren().size()];	
		}
		
		List<MenuDO> list=menu.getChildren();
		Map<Object,Object> childMap=null;
		Map<Object,Object> attr=null;
		for(MenuDO child:list){
			childMap=new HashMap<Object,Object>();
			attr=new HashMap<Object,Object>();
//			childMap.put("attr",attr);
			childMap.put("data",child.getName());
			childMap.put("metadata",child.getName());
			if (child.getChildren()!=null){
				childMap.put("children", null);	
			}
//			attr.put("id", menu.getId());
		}
		
		return null;
	}
}
